import { outputFile } from 'fs-extra';
import path from 'path';
import { generateFavicons } from '../generateFavicons.js';
export const updateFavicons = async (mintConfig, contentDirectoryPath) => {
    const generatedFavicons = await generateFavicons(mintConfig, contentDirectoryPath);
    if (!generatedFavicons)
        return;
    const promises = [];
    generatedFavicons.images.forEach((img) => {
        promises.push((async () => {
            const targetPath = path.join('public', 'favicons', img.name);
            await outputFile(targetPath, Buffer.from(img.contents), {
                flag: 'w',
            });
        })());
    });
    generatedFavicons.files.forEach((file) => {
        promises.push((async () => {
            const targetPath = path.join('public', 'favicons', file.name);
            await outputFile(targetPath, file.contents, { flag: 'w' });
        })());
    });
    await Promise.all(promises);
};
